<template>
  <div class="brandDeyail">
    <header-tm></header-tm>
    <div class="banner">
        <img :src="list.data.list_pic_url" alt="">
        <span>MUJI制造商</span>
    </div>
    <div class="info">{{list.data.simple_desc}}</div>
    <ul class="list" v-if="show">
        <li class="item" v-for="el in list.goodsList" :key="el.id">
            <img :src="el.list_pic_url">
            <p class="cname">{{el.name}}</p>
            <p class="price">¥{{el.retail_price}}</p>
        </li>
    </ul>
    <div class="null" v-else>数据库暂无数据...</div>
  </div>
</template>
<script>
import Head from "../components/Header";
import { mapState } from "vuex";
import { detailaction } from "@/api/home/index"
export default {
  data() {
    return {
        id:"",
        list:{data:{list_pic_url:'',simple_desc:""}},
        show:true
    };
  },
  computed: {
    ...mapState(["brandId"]),
  },
  methods: {
    init() {
        if (this.brandId != "") {
            localStorage.setItem("uid",JSON.stringify(this.brandId))
        }
        this.id = JSON.parse(localStorage.getItem("uid"))
      detailaction({ id:this.id}).then((res) => {
          if(res.goodsList == false) {
              this.show = false
          }
          this.list = res
        console.log(res);
      });
    },
  },
  mounted() {
      this.init()
  },
  components: {
    "header-tm": Head,
  },
};
</script>
<style lang="scss" scoped>
.brandDeyail {
    height: 100vh;
    background-color: #f4f4f4;
}
.banner {
    position: relative;
    width: 100%;
    height: 145px;
    img {
        display: block;
        width: 100%;
        height: 145px;
    }
    span {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-50%);
        font-size: 19px;
        padding: 2.5px;
        border-bottom: 2px solid #fff;
        color: #fff;
    }
}
.info {
    font-size: 15px;
    padding: 21px 16px;
    background-color: #fff;
    margin-bottom: 10px;
}
.list {
    background-color: #fff;
        overflow: hidden;
        border-top: 2px solid #f4f4f4;
        border-bottom: 2px solid #f4f4f4;
        .item {
            float: left;
            width: 50%;
            height: 242px;
            box-sizing: border-box;
            img {
                display: block;
                width: 150px;
                height: 150px;
                margin: 0 auto;
            }
            .price {
                font-size: 15px;
                color: #b4282d;
            }
            .cname {
                padding: 0 10px;
            }
            &:nth-child(odd) {
                border-right: 2px solid #f4f4f4;
                border-bottom: 2px solid #f4f4f4;
            }
            &:nth-child(even) {
                border-bottom: 2px solid #f4f4f4;
            }
        }
    }
.null {
    margin-top: 100px;
    font-size: 16px;
    color: #999;
}
</style>
